package com.wzy.alllearning.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import lombok.extern.slf4j.Slf4j;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler
{
	@ExceptionHandler(BusinessException.class)
	public void businessException(BusinessException ex)
	{
		log.error("捕获业务异常：{} ", ex);
	}

	@ExceptionHandler(RuntimeException.class)
	public void runtimeException(RuntimeException ex)
	{
		log.error("捕获运行时异常：{} ", ex);
	}

	/**
	 * 捕捉系统异常
	 */
	@ExceptionHandler(Throwable.class)
	public void throwableHandler(Throwable ex)
	{
		log.error("捕获系统异常：{} ", ex);
	}
}
